<!DOCTYPE html>
<html lang="zh">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="icon" href="{{ url_for('admin.static', filename='images/favicon.ico')}}">

        <title>{% block title %}何三笔记 {% endblock %}</title>
        {% block css %}
            <!-- 新 Bootstrap 核心 CSS 文件 -->
            <link rel="stylesheet" href="https://s1.pstatp.com/cdn/expire-1-M/twitter-bootstrap/3.3.5/css/bootstrap.min.css">

            <!-- 可选的Bootstrap主题文件（一般不用引入） -->
            <link rel="stylesheet" href="https://s3.pstatp.com/cdn/expire-1-M/twitter-bootstrap/3.3.5/css/bootstrap-theme.min.css">

            <!-- 个性化主题文件 -->

            <link href="{{ url_for('admin.static', filename='css/admin.css')}}" rel="stylesheet">
        {% endblock %}

        {% block js %}
            <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
            <script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/1.11.3/jquery.min.js"></script>

            <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
            <script src="https://s1.pstatp.com/cdn/expire-1-M/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>

            <!-- 个性化 js 文件 -->
            <script src="{{ url_for('admin.static', filename='js/admin.js')}}"></script>
        {% endblock %}
        <script>
            function edit_uri(p){
                var uri = 'mysql+pymysql://root:123456@127.0.0.1/h3blog?charset=utf8';
                if(p == 1) {
                    uri = 'mysql+pymysql://root:123456@127.0.0.1/h3blog?charset=utf8'
                }else if(p == 2) {
                    uri = 'sqlite:///data-dev.db'
                }
                $('input[name="uri"]').val(uri)
            }
        </script>
    </head>

    <body>
        <div class="container">
            <div class="row">
                <div class="add-admin">
                    <div class="row">
                        <div class="col-xs-12 col-sm-offset-2">
                            <div class="col-xs-12 col-sm-8">
                                <h1 class="title">欢迎使用<a href="http://www.h3blog.com" target="_blank">H3BLOG</a>博客系统</h1>
                                <h4>连接数据库配置</h4>
                                <form method="post" role="form" action="{{url_for("admin.setup", step=2)}}">
                                    {{ form.hidden_tag() }}
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="glyphicon glyphicon-hdd"></i> </span>
                                        {{ form.uri(class="form-control", placeholder="mysql+pymysql://{账号}:{密码}@{ip:port}/{数据库}?charset=utf8", required="", autofocus="") }}
                                    </div>
                                    <div>
                                        <a href="#" onclick="edit_uri(1);">mysql配置案例：mysql+pymysql://root:123456@127.0.0.1/h3blog?charset=utf8</a>
                                        <br>
                                        <a href="#" onclick="edit_uri(2);">sqlite配置案例：sqlite:///data-dev.db</a>
                                    </div>
                                    <div class="pull-right">
                                        {{ form.submit(class="btn btn-primary") }}
                                    </div>
                                </form>
                                <div class="col-xs-12">
                                    <br>
                                    <div class="row">
                                    {% for field_name, field_errors in form.errors|dictsort if field_errors %}
                                        {% for error in field_errors %}
                                            <div class="alert alert-danger alert-dismissible" role="alert">
                                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                <strong>{{ form[field_name].label }}错误：</strong> {{ error }}
                                            </div>
                                        {% endfor %}
                                    {% endfor %}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div><!--/row-->
        </div><!--/.container-->
    </body>
</html>